Find Area of a Rhombus

Theory:

The area of a rhombus can be calculated using the formula: area = (diagonal1 * diagonal2) / 2, where diagonal1 and diagonal2 are the lengths of its diagonals.

Python Code:

def calculate_rhombus_area(diagonal1, diagonal2):
    return (diagonal1 * diagonal2) / 2

# Taking input for the diagonals of the rhombus and calculating its area
def calculate_and_display_rhombus_area():
    diagonal1 = float(input("Enter the length of the first diagonal: "))
    diagonal2 = float(input("Enter the length of the second diagonal: "))
    area = calculate_rhombus_area(diagonal1, diagonal2)
    print("Area of the rhombus:", area)

calculate_and_display_rhombus_area()

Example Output 1:

Enter the length of the first diagonal: 8

Enter the length of the second diagonal: 6

Area of the rhombus: 24.0

Example Output 2:

Enter the length of the first diagonal: 12.5

Enter the length of the second diagonal: 9.3

Area of the rhombus: 58.125

Code Explanation:

The function calculate_rhombus_area(diagonal1, diagonal2) calculates the area of a rhombus using the formula (diagonal1 * diagonal2) / 2.

The function calculate_and_display_rhombus_area() takes input for the lengths of the diagonals of the rhombus, calculates its area using the aforementioned function, and displays the result.